/**
  * Author: Mei
  * Date: 2020-12-13 9:38
  * Description: std::forward()转发
  *
  */
#include "../head.h"

using namespace std;

void process(int &i) {
    cout << "process(int&)" << endl;
}

void process(int &&i) {
    cout << "process(int&&)" << endl;
}

void forward1(int &i) {
    cout << "forward(int&&)" << endl;
    process(std::forward<decltype(i)>(i));
}

class Move_point {
private:
    char *data;
public:
    Move_point() {
        data = new char[10];
        strcpy(data, "data");
    }
    Move_point(const Move_point &mo) : data(mo.data) {
        cout << "Move_point&" << endl;
    }

    Move_point(Move_point &&mo) : data(mo.data) {
        cout << "Move_point&&" << endl;
        data = mo.data;
        mo.data = NULL;
    }
    void display() {
        cout << string(data) << endl;
    }
    ~Move_point(){
        cout << "xigou" << endl;
        if(data != NULL) {
            delete[] data;
        }
    }
};
void forwardd(Move_point &&mp) {
    mp.display();
    Move_point mo2(forward<Move_point>(mp));
    mo2.display();
    //mp.display();
}
int main() {
    //Move_point mo1;
    //mo1.display();
    forwardd(Move_point());
    //mo1.display();


    return 0;
}